Function IsEntityInViewArea( ScrEntity , DstEntity , ViewAngle )
	
	Angle# = GetXZAngle( ScrEntity , DstEntity )
						
	MaxHittingAngle# = EntityYaw( DstEntity ) + (ViewAngle / 2)
	MinHittingAngle# = EntityYaw( DstEntity ) - (ViewAngle / 2)
	
	MaxHittingPass = False
	MinHittingPass = False
	
	If MaxHittingAngle > 180 Then MaxHittingAngle = MaxHittingAngle - 360
	If MinHittingAngle > 180 Then MinHittingAngle = MinHittingAngle - 360
	If MaxHittingAngle < -180 Then MaxHittingAngle = MaxHittingAngle + 360
	If MinHittingAngle < -180 Then MinHittingAngle = MinHittingAngle + 360
	
	If EntityYaw( DstEntity ) > MaxHittingAngle							
		If Angle > EntityYaw( DstEntity ) Or Angle < MaxHittingAngle
			MaxHittingPass = True
		End If
	Else
		If Angle > EntityYaw( DstEntity ) And Angle < MaxHittingAngle
			MaxHittingPass = True
		End If							
	End If
	
	If EntityYaw( DstEntity ) < MinHittingAngle							
		If Angle < EntityYaw( DstEntity ) Or Angle > MinHittingAngle
			MinHittingPass = True
		End If							
	Else							
		If Angle < EntityYaw( DstEntity ) And Angle > MinHittingAngle
			MinHittingPass = True
		End If							
	End If
	
	If MinHittingPass = True Or MaxHittingPass = True Then Return True
	
End Function

Function GetEntityViewAngle( ScrEntity , DstEntity )
	
	Angle# = GetXZAngle( ScrEntity , DstEntity )
						
	ChangeAngle# = EntityYaw( ScrEntity ) - EntityYaw( DstEntity )
	
	If ChangeAngle > 180 Then ChangeAngle = ChangeAngle - 360
	If ChangeAngle > 180 Then ChangeAngle = ChangeAngle - 360
	If ChangeAngle < -180 Then ChangeAngle = ChangeAngle + 360
	If ChangeAngle < -180 Then ChangeAngle = ChangeAngle + 360
	
	Return ChangeAngle
	
End Function

Function GetXZAngle( ScrEntity , DstEntity )	
	Return ( ATan2( EntityX( ScrEntity ) - EntityX( DstEntity ) , EntityZ( ScrEntity ) - EntityZ( DstEntity ) ) )	
End Function

Function GetXYAngle( ScrEntity , DstEntity )	
	Return ( ATan2( EntityX( ScrEntity ) - EntityX( DstEntity ) , EntityY( ScrEntity ) - EntityY( DstEntity ) ) )	
End Function

Function GetZYAngle( ScrEntity , DstEntity )	
	Return ( ATan2( EntityZ( ScrEntity ) - EntityZ( DstEntity ) , EntityY( ScrEntity ) - EntityY( DstEntity ) ) )	
End Function